<?php


public function index(){  

Vendor('jssdks');
$city = "天津"
$map = $this->addresstolatlag($a);
$this->assign('city',$city);
$this->assign('map',$map);
$this -> display('index');

}



/**
 * 获取某地址的经纬度
 * by http://www.jbxue.com
*/
function addresstolatlag($address){  
  //腾讯地图解析
      $url = 'http://apis.map.qq.com/ws/geocoder/v1/?address='.$address.'&key=3ZYBZ-Y5D3X-AMG4P-7F4EG-NYTZ7-WHB6R';
         if($result=file_get_contents($url))  
            { 
              $reslat = json_decode($result,true);
              $res['lng']= $reslat['result']['location']['lng'];
              $res['lat']= $reslat['result']['location']['lat'];
            }
             //pr($reslat);die;
      return $res;

    //百度地图解析
    //      $url='http://api.map.baidu.com/geocoder/v2/?address=天津市河西区&output=json&ak=46Wo374E900r7CIkL0dHoQiGd7a7GoFv'; 
    //      if($result=file_get_contents($url))  
    //         { 
        // $res= explode(',"lat":', substr($result, 40,36));
    //             $lng= substr($result, 40,18);
    //             $lat= substr($result, 65,17);
    //         }

    //      $urls = 'http://apis.map.qq.com/ws/coord/v1/translate?locations='.$lat.','.$lng.'&type=3&key=3ZYBZ-Y5D3X-AMG4P-7F4EG-NYTZ7-WHB6R';
    //      if($results=file_get_contents($urls))  
    //         { 

    //         }
             //pr($results);die;
            
            
     //谷歌地图解析      
    //     $url='http://maps.google.cn/maps/api/geocode/json?address=tianjin&sensor=true_or_false';

    //         if($result=file_get_contents($url))  
    //         {  
      //    $reslat = json_decode($result,true);
    //              $northeast_lat = $reslat['results']['0']['geometry']['viewport']['northeast']['lat'];
        // $southwest_lat = $reslat['results']['0']['geometry']['viewport']['southwest']['lat'];
        // $northeast_lng = $reslat['results']['0']['geometry']['viewport']['northeast']['lng'];
        // $southwest_lng = $reslat['results']['0']['geometry']['viewport']['southwest']['lng'];
        // $res['lat'] = ($northeast_lat + $southwest_lat)/2;
        // $res['lng'] = ($northeast_lng + $southwest_lng)/2;
      //    pr($result);die;
    //             return   $res;  
  
    //         } 
  
}  
?>